package com.example.library.common;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 响应状态码枚举
 *
   */
@Getter
@AllArgsConstructor
public enum ResultCode {

    // 通用状态码
    SUCCESS(200, "操作成功"),
    ERROR(500, "操作失败"),
    PARAM_ERROR(400, "参数错误"),
    NOT_FOUND(404, "资源不存在"),
    METHOD_NOT_ALLOWED(405, "请求方法不允许"),
    INTERNAL_SERVER_ERROR(500, "服务器内部错误"),

    // 认证相关
    UNAUTHORIZED(401, "未授权"),
    FORBIDDEN(403, "禁止访问"),
    TOKEN_INVALID(4001, "Token无效"),
    TOKEN_EXPIRED(4002, "Token已过期"),
    LOGIN_REQUIRED(4003, "请先登录"),
    PERMISSION_DENIED(4004, "权限不足"),

    // 用户相关
    USER_NOT_FOUND(5001, "用户不存在"),
    USER_ALREADY_EXISTS(5002, "用户已存在"),
    USERNAME_OR_PASSWORD_ERROR(5003, "用户名或密码错误"),
    USER_DISABLED(5004, "用户已被禁用"),
    OLD_PASSWORD_ERROR(5005, "原密码错误"),
    PASSWORD_NOT_MATCH(5006, "两次密码不一致"),

    // 图书相关
    BOOK_NOT_FOUND(6001, "图书不存在"),
    BOOK_ALREADY_EXISTS(6002, "图书已存在"),
    BOOK_NOT_AVAILABLE(6003, "图书不可借阅"),
    BOOK_STOCK_INSUFFICIENT(6004, "图书库存不足"),
    ISBN_ALREADY_EXISTS(6005, "ISBN已存在"),

    // 分类相关
    CATEGORY_NOT_FOUND(7001, "分类不存在"),
    CATEGORY_ALREADY_EXISTS(7002, "分类已存在"),
    CATEGORY_HAS_BOOKS(7003, "分类下存在图书，无法删除"),
    CATEGORY_HAS_CHILDREN(7004, "分类下存在子分类，无法删除"),

    // 借阅相关
    BORROW_RECORD_NOT_FOUND(8001, "借阅记录不存在"),
    BOOK_ALREADY_BORROWED(8002, "图书已被借阅"),
    BOOK_NOT_BORROWED(8003, "图书未被借阅"),
    BORROW_LIMIT_EXCEEDED(8004, "借阅数量超出限制"),
    BOOK_OVERDUE(8005, "图书已逾期"),
    CANNOT_BORROW_OWN_BOOK(8006, "不能借阅自己的图书"),
    ALREADY_RETURNED(8007, "图书已归还"),

    // 文件相关
    FILE_UPLOAD_ERROR(9001, "文件上传失败"),
    FILE_TYPE_NOT_SUPPORTED(9002, "文件类型不支持"),
    FILE_SIZE_EXCEEDED(9003, "文件大小超出限制"),
    FILE_NOT_FOUND(9004, "文件不存在"),

    // 系统相关
    SYSTEM_CONFIG_NOT_FOUND(10001, "系统配置不存在"),
    OPERATION_LOG_SAVE_ERROR(10002, "操作日志保存失败"),
    DATA_EXPORT_ERROR(10003, "数据导出失败"),
    DATA_IMPORT_ERROR(10004, "数据导入失败");

    /**
     * 状态码
     */
    private final Integer code;

    /**
     * 状态消息
     */
    private final String message;



}